//
//  NSObject+PDHud.m
//  QiXiaoFuProject
//
//  Created by mac on 16/9/11.
//  Copyright © 2016年 fhj. All rights reserved.
//

#import "NSObject+PDHud.h"
#import "SVProgressHUD.h"
#import "PDHud.h"
#import "KeybordShowSingle.h"

@implementation NSObject (PDHud)

- (void)presentMessageTips:(NSString *)message
{
    CGFloat hei  = 0;
   hei  = [KeybordShowSingle mainKeybordShowSingle].keyboardHeight;
    if (hei > 0)
    {
        [PDHud setOffsetFromCenter:UIOffsetMake(0, (KSCREENHEIGHT - hei)/2 - 100)];
    }
    else
    {
        [PDHud setOffsetFromCenter:UIOffsetMake(0, KSCREENHEIGHT/2 - 100)];
    }
    [PDHud setCornerRadius:3.0];
    [PDHud showImage:nil status:message];
}


- (void)showText:(NSString *)aText
{
    [PDHud resetPDHub];
    [PDHud showWithStatus:aText];
}

- (void)showErrorText:(NSString *)aText
{
    if(aText.length != 0){
        [PDHud resetPDHub];
        [PDHud showErrorWithStatus:aText];
    }
}

- (void)showSuccessText:(NSString *)aText
{
    if(aText.length != 0){
        [PDHud resetPDHub];
        [PDHud showSuccessWithStatus:aText];
    }
}

- (void)showLoading
{
    [PDHud show];
}


- (void)dismissLoading
{
    [PDHud dismiss];
}

- (void)showProgress:(NSInteger)progress
{
    if (progress == 100)
    {
        [self dismissLoading];
    }
    else
    {
        [PDHud resetPDHub];
        [PDHud showProgress:progress/100.0 status:[NSString stringWithFormat:@"%li%%",(long)progress]];
    }
    
}

- (void)showImage:(UIImage*)image text:(NSString*)aText
{
    [PDHud showImage:image status:aText];
}


@end
